const strs = ["flower","flow","flight"]
var longestCommonPrefix = function(strs) {
    const len=strs.length
    let prefix=strs[0]
    if(strs.length==0)
    {
        return ""
    }
    for(let i=1;i<len;i++)
    {
       while(strs[i].indexOf(prefix)!==0)
       {
         prefix=prefix.substring(0,prefix.length-1)
         if(prefix==="")return""
       }
    }
    return prefix



}(strs)
console.log(longestCommonPrefix);
